package com.wx.mall.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.wx.mall.common.api.CommonPage;
import com.wx.mall.common.exceptions.ApiAssert;
import com.wx.mall.sys.entity.LogisticsCompany;
import com.wx.mall.sys.mapper.LogisticsCompanyMapper;
import com.wx.mall.sys.service.ILogisticsCompanyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wx.mall.sys.vo.reqVo.LogisticsCompanyPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 物流公司 服务实现类
 * </p>
 *
 * @author j
 * @since 2020-03-25
 */
@Service
public class LogisticsCompanyServiceImpl extends ServiceImpl<LogisticsCompanyMapper, LogisticsCompany> implements ILogisticsCompanyService {
    @Autowired
    private LogisticsCompanyMapper logisticsCompanyMapper;

    @Override
    public List<LogisticsCompany> findPage(LogisticsCompanyPageVO vo) {
        System.out.println("kk" + vo.getPageNum());
        PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        List<LogisticsCompany> page = logisticsCompanyMapper.findPage(vo);
        return page;
    }

    @Override
    public void updateByIdGetState(Integer id, Integer state) {
        Integer integer = logisticsCompanyMapper.updateByIdGetState(id, state);
        if (integer == 0) {
            ApiAssert.fail("状态修改失败");
        }
    };

    @Override
    public LogisticsCompany findById(Integer id) {
        System.out.println(id);
        return logisticsCompanyMapper.findById(id);
    };

    @Override
    public int updateOne(LogisticsCompany logisticsCompany) {

        return  logisticsCompanyMapper.updateOne(logisticsCompany);
    }
}
